<% content_for :action_nav do %>
<!-- begin action nav -->
<div id="page-nav">
  <ul id="act-nav" class="clear">
    <li><%= link_to _("Create new article"), :action => "new" %></li>
  </ul>
</div>
<!-- /end action nav -->
<div id="filter" class="manual">
  <ul class="clear">
    <li><a href="#">&nbsp;</a></li>
  </ul>
  <% form_tag({:action => 'index'}, :method => 'get', :id => 'article-search') do -%>
  <ul id="attributes">
    <li><label for="search"><%= _('Show articles:') %></label></li>
    <li>
      <select name="filter" id="filterlist">
        <%= options_for_select [
          [_('in section'),           'section'],
          [_('tagged with'),          'tags'],
          [_('whose title contains'), 'title'],
          [_('whose body contains'),  'body'],
          [_('not published'),        'draft']
        ] %>
      </select>
      <select name="section" id="sectionlist">
        <option value="0">&mdash;<%= _('All Sections') %>&mdash;</option>
        <%= options_from_collection_for_select @sections, :id, :name, params[:section].to_i %>
      </select>
    </li>
    <li><%= text_field_tag 'q', params[:q], :id => 'manualsearch', :style => 'display:none' %></li>
    <li><input type="button" id="searchsubmit" value="Go" style="display:none" /></li>
  </ul>
    <div><%= hidden_field_tag :published, 1 %></div>
  <% end -%>
</div>
<% end %>

<% if @articles.any? %>
<!-- begin article list -->
<table id="article-list" cellspacing="0" cellpadding="0">
  <thead>
    <tr>
      <th scope="col" class="small-col"><%= _('Status') %></th>
      <th scope="col"><%= _('Article') %></th>
      <th scope="col"><%= _('Comments') %></th>
      <th scope="col"><%= _('Published') %></th>
      <th scope="col">&nbsp;</th>
    </tr>
  </thead>
  <tbody id="articles">
      <%= render :partial => 'article', :collection => @articles %>
  </tbody>
</table>
<!-- /end article list -->


<!-- begin pagination -->
<div id="pagination">
<% if @article_pages.page_count > 1 -%>
Pages: <strong><%= pagination_links @article_pages, :params => { :action => :index } %></strong>
<% end -%>
</div>
<!-- /end pagination -->

<% else %>
  <div class="empty" style="margin-bottom:20px">
    <% unless params[:filter] %>
      <%= _('You have no articles.') %>  <%= link_to _("Create one now "), :action => "new" %>
    <% else %>
      <%= _("You don't seem to have any articles matching that criteria.") %>
    <% end %>
  </div>
<% end %>

<% content_for :sidebar do %>
  <% if @comments.any? -%>
  <div class="sgroup">
    <h3><%= _('Comments awaiting your approval') %></h3>
    <ul class="slist">
    <% @comments.each do |article, count| -%>
      <li><%= link_to _("<strong>(%{count})</strong> %{title}") % {:count => count, :title => h(article.title)}, :controller => 'articles', :action => 'comments', :id => article.id, :filter => :unapproved %></li>
    <% end -%>
    </ul>
  </div>
  <% end -%>
<% end %>
